<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .fade-enter{
            opacity: 0;
        }
        .fade-enter-active{
            opacity: 1;
            transition:all 1s linear;
        }
        .fade-leave{
            opacity: 1;
        }
        .fade-leave-active{
            opacity: 0;
            transition: all 1s linear;
        }
    </style>
</head>
<body>
    <div id="app">
        <input type="checkbox" v-model='isshow'>
        <!--
            现象：当有相同标签名的元素切换时,Vue只会替换相同标签内部的内容
            解决：加上key属性作为唯一的值来标记让Vue区分
        -->
        <transition name='fade' mode="out-in">
            <button v-if='isshow' key='show'>显示</button>
            <button v-else key='hide'>隐藏</button>
        </transition>
        
    </div>
    <script src='vue.js'></script>
    <script>
        new Vue({
            el:'#app',
            data:{
                isshow:true,
            }
        })
    </script>
</body>
</html>